<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
        .likebtn {
            background: #ff69b4;
        }
    </style>
</head>
<body>
    <div id="app">
        <like></like>
        <like></like>
        <like></like>
        <like></like>
    </div>
</body>
<script type="text/javascript" src="js/vue.js"></script>
<script>
    Vue.component('like', {
        template: '<button :class="{likebtn: liked}" @click="toggleLike()">赞 {{ count }}</button>',
        data: function() {
            return {
                liked: false,
                count: 0 
            }
        },
        methods: {
            toggleLike: function() {
                this.liked = true; 
                this.count += 1;
            }
        }
    });
    new Vue({
        el: "#app"
    });
    // 作业,点赞变成粉色,一直加1 赞1 赞5
</script>
</html>
